package com.ysm.smfu.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.ysm.smfu.R;
import com.ysm.smfu.utils.UIUtils;

/**
 * Created by Administrator on 2017/3/29.
 */
public class AllFoodAdapter extends RecyclerView.Adapter<AllFoodAdapter.MyHolder> {

    private String[] foods;
    private String[] count;

    public AllFoodAdapter(String[] foods,String[] count){
        this.foods=foods;
        this.count=count;
    }

    @Override
    public MyHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(UIUtils.getContext()).inflate(R.layout.all, null);
        return new MyHolder(view);
    }

    @Override
    public void onBindViewHolder(MyHolder holder, int position) {
        holder.setData(foods[position], count[position]);
    }

    @Override
    public int getItemCount() {
        return foods.length;
    }

    class MyHolder extends RecyclerView.ViewHolder {

        private final TextView only_FreeYuYue;
        private final TextView num;

        public MyHolder(View itemView) {
            super(itemView);
            only_FreeYuYue = (TextView) itemView.findViewById(R.id.only_FreeYuYue);
            num = (TextView) itemView.findViewById(R.id.num);
        }

        public void setData(String str, String numS) {
            only_FreeYuYue.setText(str);
            num.setText(numS);

        }
    }
}
